<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/extends/zTree_v3/css/zTreeStyle/zTreeStyle.css"/>
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>
    <div style="position: relative;height: 100%;" >
        <!-- 机构树 -->
        <!--
        <div class="ccpui-trees">
                <p class="isShowTree colorSwitch">
                    <span style="float: left;color: #fff">&nbsp;&nbsp;组织机构管理</span>
                    <i layadmin-event="treeFlexible" class="layui-icon layui-icon-prev"></i>
                </p>
                <div style="margin-top: 6px;">
                    <ul class="ccpui-iconTree iconTrees">
                        <li><a class="iconfont iconshuaxin- zTree-refresh" title="刷新"></a></li>
                        <li><a class="iconfont iconwenjianjia1-copy zTree-triangle-d" title="展开"></a></li>
                        <li><a class="iconfont iconfolder1 zTree-triangle-r" title="收起"></a></li>
                            <input type="text"  style="width: 50%" class="orgZtreeValue">
                    </ul>
                    <ul id="treeSelectUsers" class="ztree ccpui-listZtree"></ul>
                </div>
        </div>
        -->
    <!--初表-->
        <div>
            <table id="demoListTable" lay-filter="demoListTable"></table>
        </div>
    </div>
    <!--给用户分配组织-->
    <div hidden name="configOrgDiv" style="display: none">
        <ul class="ccpui-iconTree orgSelectBtn">
            <li><a class="iconfont iconshuaxin- zTree-refresh" title="刷新"></a></li>
            <li><a class="iconfont iconwenjianjia1-copy zTree-triangle-d" title="展开"></a></li>
            <li><a class="iconfont iconfolder1 zTree-triangle-r" title="收起"></a></li>
            <input type="text"  style="width: 128px" class="orgZtreeValues">
        </ul>
        <ul id="configOrgData" class="ztree" style="height: 450px;overflow: auto"></ul>
        <div style="text-align: center;margin-bottom: 14px">
            <button class="layui-btn saveOrg">保存</button>
            <button class="layui-btn layui-btn-danger cancelOrg">取消</button>
        </div>
    </div>
    <!-- 用户信息列表头部工具栏 -->

    <script type="text/html" id="headerToolsBar">
        <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon">&#xe654;</i>
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon">&#xe615;</i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <i class="layui-icon">&#xe9aa;</i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="example" style="margin-top:10px">
            <div class="table-top-filter">
                <div class="table-filter-alone">
                    <label class="layui-form-label">示例名称</label>
                    <input type="text" class="layui-input filter-value" name="Q_demoName_SL" />
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label">示例类型</label>
                    <select class="filter-value" name="demoType">
                        <option value="">-----请选择----</option>
                        <option value="0">状态0</option>
                        <option value="1">状态1</option>
                    </select>
                </div>
                <div class="table-filter-alone">
                    <label class="layui-form-label">示例时间</label>
                    <input type="text" name="Q_startTime_DL" autocomplete="off" placeholder="开始时间"
                        class="layui-input start_time filter-value">
                    <span style="float:left;margin-left:38px">—</span>
                    <input type="text" name="Q_endTime_DG" autocomplete="off" placeholder="结束时间"
                        class="layui-input end_time filter-value" style="margin-left:38px">
                </div>
            </div>
        </form>
        </div>
    </script>
    <script type="text/html" id="demoRightToolsBar">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            {{# if(d.demoType == 0){ }}
            <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">状态0删除</button>
            {{# }else{ }}
            <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" >状态1删除</button>
            {{# } }}
    </script>
    <div>
    </div>
    <script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
    <script src="${ctx}/public/component.js" type="text/javascript"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <!--<script src="${ctx}/extends/zTree_v3/js/jquery.ztree.all.min.js" type="text/javascript"></script>-->
    <!--<script src="${ctx}/extends/zTree_v3/js/jquery.ztree.exhide.min.js" type="text/javascript"></script>-->
    <script>
        layui.config({
            base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index','table', 'layer', 'form', 'laydate', 'totalFilter', 'setter','upload','commons','common'], function() {
                var table = layui.table;
                var layer = layui.layer,totalFilter = layui.totalFilter,form = layui.form,$ = layui.jquery,setter = layui.setter,upload=layui.upload,commons=layui.commons,common=layui.common;
            var tableHeight = commons.tabHeight();
                //初表
                table.render({
                    elem: '#demoListTable',
                    cellMinWidth: 80,
                    title: '示例列表',
                    height: tableHeight,
                    url: serverPath.systemPath +'/demo/demo/demo', //数据接口
                    page: true, //开启分页
                    method: 'get',
                    defaultToolbar: ['filter', 'print'],
                    toolbar: '#headerToolsBar',
                    autoSort: false,//禁用前端排序
                    cols: [
                        [
                            {type: 'checkbox'},
                            {field: 'demoId', title: 'ID', sort: true, hide: true},
                            {field: 'demoName',align:'center', title: '示例名称', sort: true},
                            {field: 'demoType',align:'center',title: '示例类型', sort: false, templet: function (d) {
                                    if (d.demoType == '0') {
                                        return '状态0';
                                    }
                                    if (d.demoType == '1') {
                                        return '状态1';
                                    }
                                    return '';
                                }
                            },
                            {align: 'center', title: '管理', toolbar: '#demoRightToolsBar'}
                        ]
                    ]
                });
                totalFilter.init('demoListTable');

                //监听用户信息列表头部工具栏事件
                table.on('toolbar(demoListTable)', function(obj) {
                    var checkStatus = table.checkStatus(obj.config.id);
                    var data = checkStatus.data;
                    switch (obj.event) {
                        case 'add':
                            layer.open({
                                type: 2,
                                area: ['450px', '240px'],
                                title: ['新增示例信息', 'font-size:18px;'],
                                content: serverPath.systemPath + '/demo/demo/view/demoAdd'
                            });
                            break;
                        case 'query':
                            common.tableConditionRender("demoListTable","example",{where:{}},false);
                            commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                            break;
                        case 'clears':
                            common.tableConditionRender("demoListTable","example",{where:{}},true);
                            commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                            break;
                    }
                });

                //监听行工具事件
                table.on('tool(demoListTable)', function(obj) {
                    var data = obj.data, //获得当前行数据
                        layEvent = obj.event; //获得 lay-event 对应的值
                    switch(layEvent){
                        case 'del':
                            layer.confirm('确定删除当前数据吗？', function(index) {
                                layer.close(index);
                                $.ajax({
                                    url: serverPath.systemPath + "/demo/demo/"+obj.data.demoId,
                                    type: "DELETE",
                                    dataType: 'json',
                                    success: function(data) {
                                        if (commons._filterRecord(data)) {
                                            layer.alert(data.msg);
                                            table.reload('demoListTable', {
                                                page: {curr: 1}
                                            });
                                            totalFilter.init('demoListTable');
                                            commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                                        } else {
                                            layer.alert(data.msg);
                                        }
                                    }
                                })
                            });
                            break;
                        case 'edit':
                            layer.open({
                                type: 2,
                                area: ['450px', '240px'],
                                title: ['修改用户信息'],
                                content: serverPath.systemPath + '/demo/demo/view/demoEdit?demoId='+data.demoId
                            });
                            break;
                    }
                });

                //监听删除
                window.Initialization = function () {
                    commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                };
                /*刷新时间控件*/
                commons.reflashDate({startName:'.start_time',endName:'.end_time'});
                common.tableSort("demoListTable",{show:window.Initialization});
            });
    </script>
</body>
</html>